package com.liyong.pullorder.sdk.exception;

/**
 * @author 葡萄味的萝卜
 * @date 2025/10/21 13:12
 * 限流异常
 * 核心作用：标识被平台限流的错误
 * 触发场景：请求频率超限、并发数超限
 * 处理策略：可重试，通过指数退避避免连续冲击
 */
public class RateLimitException extends PullOrderException{
    private final int retryAfterSeconds;

    public RateLimitException(String message, String platformCode) {
        super(message, "RATE_LIMIT_EXCEEDED", platformCode);
        this.retryAfterSeconds = 60; // 默认60秒后重试
    }

    public RateLimitException(String message, String platformCode, int retryAfterSeconds) {
        super(message, "RATE_LIMIT_EXCEEDED", platformCode);
        this.retryAfterSeconds = retryAfterSeconds;
    }

    public int getRetryAfterSeconds() {
        return retryAfterSeconds;
    }
}
